﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace DA6502
{
    public partial class BitLamp : UserControl
    {
        private bool _chk;
        private char _flg;

        /// <summary>
        /// 是否选中
        /// </summary>
        [Browsable(true), Description("是否选中"), EditorBrowsable(EditorBrowsableState.Always)]
        public bool Checked
        {
            get => _chk;
            set
            {
                if (value)
                {
                    BackColor = Color.Red;
                    lbl.ForeColor = Color.White;
                }
                else
                {
                    BackColor = Color.LightGray;
                    lbl.ForeColor = Color.Black;
                }
                _chk = value;
            }
        }

        /// <summary>
        /// 显示字符
        /// </summary>
        [Browsable(true), Description("显示字符"), EditorBrowsable(EditorBrowsableState.Always)]
        public char FLagName
        {
            get => _flg;
            set
            {
                if (value.ToString().Length == 1)
                {
                    _flg = value;
                    lbl.Text = value.ToString();
                }
            }
        }

        public BitLamp()
        {
            InitializeComponent();
        }

        public BitLamp(bool v)
        {
            InitializeComponent();
            Checked = v;
        }
    }
}